﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Data.Common;

using Ice.Toolkit.Data.Entity;

namespace Ice.Toolkit.Data
{
    public interface IDataContext
    {
        void TranBegin();
        void TranCommit();

        int Insert<TEntity>(TEntity entity) where TEntity : EntityBase<TEntity>, new();

        int Update<TEntity>(TEntity entity) where TEntity : EntityBase<TEntity>, new();

        int Delete<TEntity>(TEntity entity) where TEntity : EntityBase<TEntity>, new();

        int Delete<TEntity>(Expression<Func<TEntity, Boolean>> whereExpression) where TEntity : EntityBase<TEntity>, new();

        IQuery<TEntity> Query<TEntity>(Expression<Func<TEntity, Boolean>> expression) where TEntity : EntityBase<TEntity>, new();

        List<TEntity> Query<TEntity>(string sqlText, params DbParameter[] cmdParams) where TEntity : EntityBase<TEntity>, new();

        TEntity Single<TEntity>(string sqlText, params DbParameter[] cmdParams) where TEntity : EntityBase<TEntity>, new();
    }
}
